<?php
namespace Mob \ Controller;

use Think \ Controller;
use Think \ Hook;

class OrgaController extends BaseController {

   public function creatorClass()
   {

   	if(IS_POST)
   	{
    $teacherId = get_uid();
   	$orgaId = I('post.classId',null,'int');  //获取班级ID
    $orgaName = I('post.orgaName',null,'string');//取班级名称
    $orgaName = empty($orgaName)?$orgaId.'班':$orgaName;
    $orgaType = I('post.orgaType',3,'int');   //获取班级类型
    $schooId = I('post.schooId',10183,'int');  //学校ID
    $orga = D('Orga');
    $is_exist = $orga->is_ExistOrga($orgaId,$orgaType,$schooId);
    if($is_exist)
    {
     $data = array('status'=>0,'msg'=>'班级已经存在');
    }else
    {
    $superId = substr($orgaId,0,strlen($orgaId)-2);
    $res = $orga->add_OrgaNode($orgaId,$superId,$orgaName,$orgaType,$schooId,null,$orgaId,$superId,$teacherId);
    if($res)
    {
     $data = array('status'=>1,'msg'=>'操作成功');
    }else
    {
    // $data = array('status'=>0,'msg'=>'创建失败!');
     $data = array('status'=>0,'msg'=>M()->getLastSql());
    }
    }
    $this->ajaxReturn($data);
   	}else
   	{
   	$uid = get_uid(); //获取用户ID
   	$teacher = D('Teacher')->get_TeacherInfo($uid);
  // 	print_r($teacher);
   	$this->assign('teacher',$teacher);
   	$this->display();
   	}
   }










}



